class ApplicationController < ActionController::Base
  protect_from_forgery with: :exception
  before_action :authenticate_user!
  layout :layout_by_resource

  def layout_by_resource
    if devise_controller?
      "devise"
    else
      "application"
    end
  end
  
  protected :layout_by_resource

  def post_xml(url_string, xml_string)
    uri = URI(url_string)
    request = Net::HTTP::Post.new uri
    request.body = xml_string
    request.content_type = 'text/xml'
    response = Net::HTTP.new(uri.host, uri.port).start { |http| http.request request }  
    response.body
  end
end
